package util;

public class Pager {
    private int currentPage;
    private int pageSize = 4;
    private int totalSize;
    private int totalPage;
    private boolean hasFirst;
    private boolean hasPrevious;
    private boolean hasNext;
    private boolean hasLast;

    public Pager(int currentPage, int totalSize) {
        this.currentPage = currentPage;
        this.totalSize = totalSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }

    private int getTotalPage() {
        totalPage = totalSize / pageSize;
        if (totalSize % pageSize != 0)
            totalPage++;
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    private boolean isHasFirst() {
        return currentPage != 1;
    }

    public void setHasFirst(boolean hasFirst) {
        this.hasFirst = hasFirst;
    }

    public boolean isHasPrevious() {
        return isHasFirst();
    }

    public void setHasPrevious(boolean hasPrevious) {
        this.hasPrevious = hasPrevious;
    }

    public boolean isHasNext() {
        return isHasLast();
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }

    private boolean isHasLast() {
        return currentPage != getTotalPage();
    }

    public void setHasLast(boolean hasLast) {
        this.hasLast = hasLast;
    }
}

